package com.getan.boot.module.system.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.getan.boot.common.annotation.Dict;
import com.getan.boot.jdbc.entity.GenericEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.List;
import java.util.Map;

/**
 * 系统权限
 *
 * @author Bruce.Gong
 * @since 1.0.0-SNAPSHOT
 */
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@Data
@TableName(value = "t_sys_permission", autoResultMap = true)
public class PermissionEntity extends GenericEntity {

    @TableId
    private Long id;
    private Long pid;
    /**
     * 权限名称
     */
    private String name;
    /**
     * 权限类型
     */
    @Dict(value = "permission_type", desc = "1菜单，2按钮")
    private Integer type;
    /**
     * 图标
     */
    private String icon;
    /**
     * 访问路径
     */
    private String path;
    /**
     * 模板路径
     */
    private String component;
    /**
     * 权限码
     */
    private String perms;
    /**
     * 排序
     */
    private Integer sort;
    /**
     * 是否显示
     */
    private Boolean visible;
    /**
     * 扩展信息
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> meta;

    @Dict(value = "common_enable_status", desc = "0正常，1停用")
    private Integer status;
    private String remark;

    @TableField(exist = false)
    private List<PermissionEntity> children;

}
